local dujiang = fk.CreateSkill({
  name = "klmou__dujiang",
  tags = { Skill.Wake },
})

Fk:loadTranslationTable{
  ["klmou__dujiang"] = "渡江",
  [":klmou__dujiang"] = "觉醒技，准备阶段，若你的护甲值不小于3，你亮出牌堆顶五张牌获得其中每种花色各一张并获得技能<a href= ':klmou__duojing'>“夺荆”</a>。",

  ["#dujiang-choose"] = "渡江：获得不同花色的牌各一张",

  ["$klmou__dujiang1"] = "渡江直上，胜利在即！",
  ["$klmou__dujiang2"] = "天险已过，准备应战！",
}

dujiang:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return player:usedSkillTimes(dujiang.name, Player.HistoryGame) == 0 and
      player:hasSkill(dujiang.name) and target == player and player.phase == Player.Start
  end,
  can_wake = function(self, event, target, player, data)
    return player.shield >= 3
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(player, "klmou__duojing")
    local cards = room:getNCards(5)
    room:moveCards({
      ids = cards,
      toArea = Card.Processing,
      moveReason = fk.ReasonJustMove,
      skillName = dujiang.name,
      proposer = player,
    })
    local get = {}
    for _, id in ipairs(cards) do
      local suit = Fk:getCardById(id).suit
      if table.every(get, function (id2)
        return Fk:getCardById(id2).suit ~= suit
      end) then
        table.insert(get, id)
      end
    end
    get = room:askToArrangeCards(player, {
      skill_name = dujiang.name,
      card_map = cards,
      prompt = "#dujiang-choose",
      free_arrange = false,
      box_size = 0,
      max_limit = {5, 4},
      min_limit = {0, #get},
      poxi_type = "shelie",
      default_choice = {{}, get},
    })[2]
    if #get > 0 then
      room:obtainCard(player, get, true, fk.ReasonPrey, player, dujiang.name)
    end
    room:cleanProcessingArea(cards)
  end,
})


return dujiang
